package controller

import (
	"gitee.com/jiebaiyou/formflow/model"
	"gitee.com/jiebaiyou/formflow/pkg/bizcode"
	"gitee.com/jiebaiyou/formflow/pkg/response"
	"github.com/gin-gonic/gin"
)

// SystemController 处理系统相关的HTTP请求
type SystemController struct {
	SystemService model.SystemService // 系统业务逻辑接口
}

// GetSystemInfo 处理获取系统信息的请求
func (sc *SystemController) GetSystemInfo(c *gin.Context) {
	info, err := sc.SystemService.GetSystemInfo(c)
	if err != nil {
		response.ServerError(c, bizcode.ServerError.String(), err)
		return
	}

	response.OK(c, bizcode.Success.String(), info)
}

// GetHealth 处理获取系统健康状态的请求
func (sc *SystemController) GetHealth(c *gin.Context) {
	health := sc.SystemService.GetHealth(c)
	if !health {
		response.ServerError(c, bizcode.ServerError.String(), health)
		return
	}

	response.OK(c, bizcode.Success.String(), nil)
}

// NotFound 处理404请求
func (sc *SystemController) NotFound(c *gin.Context) {
	response.NotFound(c, bizcode.ResourceNotFound.String(), map[string]string{
		"path": c.Request.URL.Path,
	})
}
